/***************************************************************************
                          expr_basic.h  -  description
                             -------------------
    begin                : Fri Jun 21 2002
    copyright            : (C) 2002 by Michiel Visser
    email                : 
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
 
#ifndef EXPR_BASIC_H
#define EXPR_BASIC_H

#include "mstl.h"

using namespace Obj;

namespace Expression
{

class Expr
{
public:
  inline Object *evaluateToCopy();
  virtual void evaluateToCopy(void *space); // evaluate to unowned object, or unowned copy of that object, that will be owned by caller
  inline void evaluateToPersistCopy(void *space);
  inline Object *evaluateToPersistCopy();
  virtual Object *evaluateToOriginal(); // evaluate to pointer to original object that will be shared by caller, and Garbage collected instead of deleted
  virtual void evaluateToVoid();
// use evaluateToCopy as much as possible, because evaluateToOriginal will create GC objects for non-variables
// implement evaluateToOriginal as much as possible, because it is fast, but if it can create orphan objects, evaluateToCopy must be implemented as well.
  String toTyle() const;
	IFDEBUG(virtual void printTyle() const;)
  virtual void toArray(OList::P array) const;
	Object *toArrayObject() const;
	Object *toArrayObject(int parentlevel) const;
  virtual void toExprArray(OList::P array) const;
  virtual int level() const;
  virtual ~Expr();
  void doStackOperation(void *space, Object *var/*orphan must be gc::unused after leaving this function*/, TypePtr s);
};

typedef Ptr<Expr>::Share EPtr;
typedef List<EPtr> EList;

} // namespace

#endif // FILEXXX_H
